package cn.spike.rockcc.controller;

import cn.spike.rockcc.dto.CourseEsDto;
import cn.spike.rockcc.dto.SearchDto;
import cn.spike.rockcc.result.JSONResult;
import cn.spike.rockcc.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:spike
 * @create:2023-03-16 16:57
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private ISearchService searchService;

    @PostMapping("/save")
    public JSONResult save(@RequestBody CourseEsDto courseEsDto){
        searchService.save(courseEsDto);
        return JSONResult.success();
    }

    @PostMapping("/course")
    public JSONResult searchCourse(@RequestBody SearchDto searchDto){
        return JSONResult.success(searchService.searchCourse(searchDto));
    }

}

